<template>
  <div class="dept-management-container">
    <!-- 页面标题 -->
    <div class="page-header">
      <h1 class="page-title">学生管理</h1>
      <el-button 
        type="primary" 
        class="add-btn" 
        @click="openDialog"
      >
        <el-icon><Plus /></el-icon>
        <span>新增学生</span>
      </el-button>
    </div>
    
    <!-- 搜索区域 -->
    <el-card class="search-card">
      <el-form :inline="true" class="search-form">
        <el-form-item label="查询方式">
          <el-select v-model="searchType" style="width: 100px">
            <el-option label="按ID" value="id" />
            <el-option label="按姓名" value="name" />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-input 
            v-model="searchKeyword" 
            :placeholder="`请输入学生${searchType === 'id' ? 'ID' : '姓名'}`" 
            clearable 
            @keyup.enter="searchStudent"
            class="search-input"
          >
            <template #prefix>
              <el-icon class="search-icon"><Search /></el-icon>
            </template>
          </el-input>
        </el-form-item>
        <el-form-item>
          <el-button 
            type="primary" 
            @click="searchStudent"
            class="search-btn"
          >
            <el-icon><Search /></el-icon>
            <span>查询</span>
          </el-button>
          <el-button 
            @click="resetSearch"
            class="reset-btn"
          >
            <el-icon><Refresh /></el-icon>
            <span>重置</span>
          </el-button>
        </el-form-item>
      </el-form>
    </el-card>
    
    <!-- 数据表格区域 -->
    <el-card class="data-card">
      <!-- 批量删除按钮移到左侧 -->
      <div class="batch-delete-container">
        <el-button 
          type="danger" 
          :disabled="selectedStudentIds.length === 0"
          @click="batchDeleteStudent"
          class="action-btn delete-btn"
        >
          <el-icon><Delete /></el-icon>
          <span>批量删除</span>
        </el-button>
      </div>

      <el-table 
        :data="tableData" 
        stripe 
        border 
        fit
        highlight-current-row
        class="dept-table"
        @selection-change="handleSelectionChange"
      >
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column type="index" label="序号" width="80" align="center" />
        <el-table-column prop="name" label="姓名" width="150" align="center" />
        <el-table-column prop="no" label="学号" width="150" align="center" />
        <el-table-column prop="gender" label="性别" width="100" align="center">
          <template #default="scope">
            {{ scope.row.gender === 1? '男' : '女' }}
          </template>
        </el-table-column>
        <el-table-column prop="phone" label="手机号" width="150" align="center" />
        <el-table-column prop="idCard" label="身份证号" width="200" align="center" />
        <el-table-column prop="degree" label="学历" width="120" align="center">
          <template #default="scope">
            {{ educationLevelMap[scope.row.degree] || '-' }}
          </template>
        </el-table-column>
        <el-table-column prop="graduationDate" label="毕业日期" width="150" align="center">
          <template #default="scope">
            {{ scope.row.graduationDate || '-' }}
          </template>
        </el-table-column>
        <el-table-column prop="clazzId" label="班级ID" width="130" align="center" />
        <el-table-column prop="isCollege" label="是否高校" width="100" align="center">
          <template #default="scope">
            {{ scope.row.isCollege === 1? '是' : '否' }}
          </template>
        </el-table-column>
        <el-table-column prop="address" label="地址" width="200" align="center" />
        <el-table-column prop="violationCount" label="违规次数" width="100" align="center" />
        <el-table-column prop="violationScore" label="违规分数" width="100" align="center" />
        <el-table-column prop="createTime" label="创建时间" width="180" align="center" />
        <el-table-column prop="updateTime" label="更新时间" width="180" align="center" />
        <el-table-column label="操作" align="center" width="200">
          <template #default="scope">
            <el-button 
              size="small" 
              type="primary" 
              @click="openEditDialog(scope.row)"
              class="action-btn edit-btn"
            >
              <el-icon><Edit /></el-icon>
              <span>修改</span>
            </el-button>
            <el-button 
              size="small" 
              type="danger" 
              @click="deleteStudent(scope.row.id, scope.row.name)"
              class="action-btn delete-btn"
            >
              <el-icon><Delete /></el-icon>
              <span>删除</span>
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      
      <!-- 分页组件居中 -->
      <div class="pagination-container-center">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage"
          :page-sizes="[5, 10, 20, 50]"
          :page-size="pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
          background
        />
      </div>
    </el-card>

    <!-- 新增学生对话框 -->
    <el-dialog
      v-model="dialogVisible"
      title="新增学生"
      width="500px"
      :before-close="handleDialogClose"
      class="form-dialog"
    >
      <template #title>
        <el-icon><User /></el-icon>
        <span>新增学生</span>
      </template>
      <el-form
        :model="studentForm"
        :rules="rules"
        ref="studentFormRef"
        label-width="100px"
        class="dialog-form"
      >
        <el-form-item label="姓名" prop="name">
          <el-input v-model="studentForm.name" />
        </el-form-item>
        <el-form-item label="学号" prop="no">
          <el-input v-model="studentForm.no" />
        </el-form-item>
        <el-form-item label="性别" prop="gender">
          <el-select v-model="studentForm.gender" style="width: 100%">
            <el-option label="女" :value="0" />
            <el-option label="男" :value="1" />
          </el-select>
        </el-form-item>
        <el-form-item label="手机号" prop="phone">
          <el-input v-model="studentForm.phone" />
        </el-form-item>
        <el-form-item label="身份证号" prop="idCard">
          <el-input v-model="studentForm.idCard" />
        </el-form-item>
        <el-form-item label="学历" prop="degree">
          <el-select v-model="studentForm.degree" style="width: 100%">
            <el-option label="初中" :value="1" />
            <el-option label="高中" :value="2" />
            <el-option label="大专" :value="3" />
            <el-option label="本科" :value="4" />
            <el-option label="硕士" :value="5" />
            <el-option label="博士" :value="6" />
            <el-option label="其他" :value="7" />
          </el-select>
        </el-form-item>
        <el-form-item label="毕业日期" prop="graduationDate">
          <el-date-picker
            v-model="studentForm.graduationDate"
            type="date"
            placeholder="选择毕业日期"
            value-format="YYYY-MM-DD"
            style="width: 100%"
          />
        </el-form-item>
        <el-form-item label="班级ID" prop="clazzId">
          <el-input v-model="studentForm.clazzId" />
        </el-form-item>
        <el-form-item label="是否高校" prop="isCollege">
          <el-select v-model="studentForm.isCollege" style="width: 100%">
            <el-option label="否" :value="0" />
            <el-option label="是" :value="1" />
          </el-select>
        </el-form-item>
        <el-form-item label="地址" prop="address">
          <el-input v-model="studentForm.address" />
        </el-form-item>
        <el-form-item label="违规次数" prop="violationCount">
          <el-input-number v-model="studentForm.violationCount" />
        </el-form-item>
        <el-form-item label="违规分数" prop="violationScore">
          <el-input-number v-model="studentForm.violationScore" />
        </el-form-item>
      </el-form>
      <template #footer>
        <el-button @click="dialogVisible = false" class="dialog-btn cancel-btn">
          <el-icon><Close /></el-icon>
          <span>取消</span>
        </el-button>
        <el-button 
          type="primary" 
          @click="addStudent"
          class="dialog-btn confirm-btn"
        >
          <el-icon><Check /></el-icon>
          <span>确定</span>
        </el-button>
      </template>
    </el-dialog>

    <!-- 修改学生对话框 -->
    <el-dialog
      v-model="editDialogVisible"
      title="修改学生"
      width="500px"
      :before-close="handleDialogClose"
      class="form-dialog"
    >
      <template #title>
        <el-icon><User /></el-icon>
        <span>修改学生</span>
      </template>
      <el-form
        :model="editStudentForm"
        :rules="rules"
        ref="editStudentFormRef"
        label-width="100px"
        class="dialog-form"
      >
        <el-form-item label="姓名" prop="name">
          <el-input v-model="editStudentForm.name" />
        </el-form-item>
        <el-form-item label="学号" prop="no">
          <el-input v-model="editStudentForm.no" />
        </el-form-item>
        <el-form-item label="性别" prop="gender">
          <el-select v-model="editStudentForm.gender" style="width: 100%">
            <el-option label="女" :value="0" />
            <el-option label="男" :value="1" />
          </el-select>
        </el-form-item>
        <el-form-item label="手机号" prop="phone">
          <el-input v-model="editStudentForm.phone" />
        </el-form-item>
        <el-form-item label="身份证号" prop="idCard">
          <el-input v-model="editStudentForm.idCard" />
        </el-form-item>
        <el-form-item label="学历" prop="degree">
          <el-select v-model="editStudentForm.degree" style="width: 100%">
            <el-option label="初中" :value="1" />
            <el-option label="高中" :value="2" />
            <el-option label="大专" :value="3" />
            <el-option label="本科" :value="4" />
            <el-option label="硕士" :value="5" />
            <el-option label="博士" :value="6" />
            <el-option label="其他" :value="7" />
          </el-select>
        </el-form-item>
        <el-form-item label="毕业日期" prop="graduationDate">
          <el-date-picker
            v-model="editStudentForm.graduationDate"
            type="date"
            placeholder="选择毕业日期"
            value-format="YYYY-MM-DD"
            style="width: 100%"
          />
        </el-form-item>
        <el-form-item label="班级ID" prop="clazzId">
          <el-input v-model="editStudentForm.clazzId" />
        </el-form-item>
        <el-form-item label="是否高校" prop="isCollege">
          <el-select v-model="editStudentForm.isCollege" style="width: 100%">
            <el-option label="否" :value="0" />
            <el-option label="是" :value="1" />
          </el-select>
        </el-form-item>
        <el-form-item label="地址" prop="address">
          <el-input v-model="editStudentForm.address" />
        </el-form-item>
        <el-form-item label="违规次数" prop="violationCount">
          <el-input-number v-model="editStudentForm.violationCount" />
        </el-form-item>
        <el-form-item label="违规分数" prop="violationScore">
          <el-input-number v-model="editStudentForm.violationScore" />
        </el-form-item>
      </el-form>
      <template #footer>
        <el-button @click="editDialogVisible = false" class="dialog-btn cancel-btn">
          <el-icon><Close /></el-icon>
          <span>取消</span>
        </el-button>
        <el-button 
          type="primary" 
          @click="updateStudent"
          class="dialog-btn confirm-btn"
        >
          <el-icon><Check /></el-icon>
          <span>确定</span>
        </el-button>
      </template>
    </el-dialog>
  </div>
</template>

<script setup lang="ts">
import { ref, computed, onMounted } from 'vue'
import type { Student } from '@/pojo/Student'
import axios from 'axios'
import { 
  ElDialog, 
  ElForm, 
  ElFormItem, 
  ElInput, 
  ElDatePicker, 
  ElMessage, 
  ElPagination, 
  ElMessageBox,
  ElSelect,
  ElOption,
  ElButton,
  ElTable,
  ElTableColumn,
  ElUpload,
  ElAvatar,
  ElImage,
  ElInputNumber,
  ElScrollbar,
  ElRadioGroup,
  ElRadioButton,
  ElLoading
} from 'element-plus'
import { 
  Plus, Search, Refresh, Edit, Delete, 
  User, Close, Check 
} from '@element-plus/icons-vue'
import type { UploadProps } from 'element-plus'

// 存储所有学生数据
const allStudentData = ref<Student[]>([])

// 分页相关数据
const currentPage = ref(1)
const pageSize = ref(5)

// 查询相关
const searchKeyword = ref('')
const searchType = ref('id')

// 选择功能
const selectedStudentIds = ref<number[]>([])

// 上传相关配置
const uploadAction = ref('http://localhost:8080/upload')
const uploadHeaders = ref({
  Authorization: 'Bearer ' + localStorage.getItem('token') || ''
})

// 学历数字与文字映射关系
const educationLevelMap = {
  1: '初中',
  2: '高中',
  3: '大专',
  4: '本科',
  5: '硕士',
  6: '博士',
  7: '其他'
}

// 计算属性
const tableData = computed(() => {
  const start = (currentPage.value - 1) * pageSize.value
  const end = start + pageSize.value
  return allStudentData.value.slice(start, end)
})

const totalPages = computed(() => {
  return Math.ceil(allStudentData.value.length / pageSize.value)
})

const total = computed(() => {
  return allStudentData.value.length
})

// 数据加载
const loadAllData = async () => {
  try {
    const result = await axios.get('http://localhost:8080/student')
    allStudentData.value = result.data.data || []
    selectedStudentIds.value = []
  } catch (error) {
    console.error('加载学生数据失败', error)
    ElMessage.error('加载学生数据失败')
  }
}

// 查询功能
const searchStudent = async () => {
  if (!searchKeyword.value.trim()) {
    await loadAllData()
    currentPage.value = 1
    return
  }
  
  try {
    if (searchType.value === 'id') {
      const result = await axios.get(`http://localhost:8080/student/${searchKeyword.value}`)
      allStudentData.value = result.data.data? [result.data.data] : []
      if (allStudentData.value.length === 0) {
        ElMessage.warning('未找到匹配的学生')
      }
    } else {
      const encodedName = encodeURIComponent(searchKeyword.value)
      const result = await axios.get(`http://localhost:8080/student/name?name=${encodedName}`)
      allStudentData.value = result.data.data || []
      if (allStudentData.value.length === 0) {
        ElMessage.warning('未找到匹配的学生')
      }
    }
    currentPage.value = 1
  } catch (error) {
    console.error('查询学生失败', error)
    ElMessage.error('查询学生失败')
  }
}

const resetSearch = async () => {
  searchKeyword.value = ''
  await loadAllData()
  currentPage.value = 1
}

// 对话框控制
const dialogVisible = ref(false)
const editDialogVisible = ref(false)

// 表单数据
const studentForm = ref<Student>({
  id: 0,
  name: '',
  no: '',
  gender: 0,
  phone: '',
  idCard: '',
  isCollege: 0,
  address: '',
  degree: 0,
  graduationDate: '',
  clazzId: 0,
  violationCount: 0,
  violationScore: 0,
  createTime: '',
  updateTime: ''
})

const editStudentForm = ref<Student>({
  id: 0,
  name: '',
  no: '',
  gender: 0,
  phone: '',
  idCard: '',
  isCollege: 0,
  address: '',
  degree: 0,
  graduationDate: '',
  clazzId: 0,
  violationCount: 0,
  violationScore: 0,
  createTime: '',
  updateTime: ''
})

// 表单验证规则
const rules = ref({
  name: [
    { required: true, message: '姓名不能为空', trigger: 'blur' },
    { max: 10, message: '姓名最长10个字符', trigger: 'blur' }
  ],
  no: [
    { required: true, message: '学号不能为空', trigger: 'blur' }
  ],
  gender: [
    { required: true, message: '性别不能为空', trigger: 'change' }
  ],
  phone: [
    { required: true, message: '手机号不能为空', trigger: 'blur' },
    { len: 11, message: '手机号必须为11位', trigger: 'blur' }
  ],
  idCard: [
    { required: true, message: '身份证号不能为空', trigger: 'blur' }
  ],
  graduationDate: [
    { required: true, message: '毕业日期不能为空', trigger: 'change' }
  ],
  clazzId: [
    { required: true, message: '班级ID不能为空', trigger: 'change' }
  ]
})

// 头像上传处理
const handleAvatarSuccess: UploadProps['onSuccess'] = (response) => {
  ElMessage.success('上传成功')
}

const handleEditAvatarSuccess: UploadProps['onSuccess'] = (response) => {
  ElMessage.success('上传成功')
}

const beforeAvatarUpload: UploadProps['beforeUpload'] = (file) => {
  const isImage = ['image/jpeg', 'image/png', 'image/gif'].includes(file.type)
  const isLt2M = file.size / 1024 / 1024 < 2

  if (!isImage) {
    ElMessage.error('只能上传 JPG/PNG/GIF 格式的图片!')
    return false
  }
  if (!isLt2M) {
    ElMessage.error('图片大小不能超过 2MB!')
    return false
  }

  return isImage && isLt2M
}

// 图片预览
const previewImage = (url: string) => {
  if (!url) {
    ElMessage.warning('暂无图片可预览')
    return
  }
  window.open(url, '_blank')
}

// 对话框操作
const openDialog = () => {
  const now = new Date().toISOString().slice(0, 19).replace('T',' ')
  studentForm.value = {
    id: 0,
    name: '',
    no: '',
    gender: 0,
    phone: '',
    idCard: '',
    isCollege: 0,
    address: '',
    degree: 0,
    graduationDate: '',
    clazzId: 0,
    violationCount: 0,
    violationScore: 0,
    createTime: now,
    updateTime: now
  }
  dialogVisible.value = true
}

const openEditDialog = (student: Student) => {
  editStudentForm.value = { ...student }
  editDialogVisible.value = true
}

// CRUD操作
const addStudent = async () => {
  try {
    const response = await axios.post('http://localhost:8080/student', studentForm.value)
    ElMessage.success('学生添加成功')
    dialogVisible.value = false
    await loadAllData()
    currentPage.value = 1
  } catch (error) {
    console.error('学生添加失败', error)
    ElMessage.error('学生添加失败')
  }
}

const updateStudent = async () => {
  try {
    const formData = { ...editStudentForm.value }
    const response = await axios.put('http://localhost:8080/student', formData)
    ElMessage.success('学生修改成功')
    editDialogVisible.value = false
    await loadAllData()
  } catch (error) {
    console.error('学生修改失败:', error)
    let errorMsg = '学生修改失败'
    if (error.response) {
      errorMsg = error.response.data?.message || 
                error.response.data?.error || 
                error.response.data?.msg ||
                error.response.statusText ||
                `请求失败，状态码: ${error.response.status}`
      if (error.response.data?.errors) {
        errorMsg = Object.values(error.response.data.errors).join(', ')
      }
    } else if (error.message) {
      errorMsg = error.message
    }
    ElMessage.error(errorMsg)
  }
}

// 分页操作
const handleCurrentChange = (page: number) => {
  currentPage.value = page
}

const handleSizeChange = (size: number) => {
  pageSize.value = size
  currentPage.value = 1
}

// 选择操作
const handleSelectionChange = (selection: any[]) => {
  selectedStudentIds.value = selection.map(item => item.id)
}

// 删除操作
const deleteStudent = (id: number, name: string) => {
  ElMessageBox.confirm(
    `确定要删除学生【${name}】吗？`,
    '提示',
    {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning',
      center: true,
      showClose: false
    }
  ).then(async () => {
    try {
      const loading = ElLoading.service({
        lock: true,
        text: '正在删除...',
        background: 'rgba(0, 0, 0, 0.1)'
      })
      
      await axios.delete(`http://localhost:8080/student/${id}`)
      ElMessage.success('学生删除成功')
      await loadAllData()
      
      if ((currentPage.value - 1) * pageSize.value >= total.value - 1) {
        currentPage.value = Math.max(1, currentPage.value - 1)
      }
      
      loading.close()
    } catch (error) {
      console.error('学生删除失败', error)
      ElMessage.error('学生删除失败')
    }
  }).catch(() => {})
}

const batchDeleteStudent = () => {
  if (selectedStudentIds.value.length === 0) {
    ElMessage.warning('请至少选择一条记录')
    return
  }
  
  const selectedNames = tableData.value
    .filter(student => selectedStudentIds.value.includes(student.id))
    .map(student => student.name)
    .join('、')
  
  ElMessageBox.confirm(
    `确定要删除选中的 ${selectedStudentIds.value.length} 名学生【${selectedNames}】吗？`,
    '提示',
    {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning',
      center: true,
      showClose: false
    }
  ).then(async () => {
    try {
      const loading = ElLoading.service({
        lock: true,
        text: '正在删除...',
        background: 'rgba(0, 0, 0, 0.1)'
      })
      
      const deletePromises = selectedStudentIds.value.map(id => 
        axios.delete(`http://localhost:8080/student/${id}`)
      )
      await Promise.all(deletePromises)
      ElMessage.success(`成功删除 ${selectedStudentIds.value.length} 名学生`)
      await loadAllData()
      selectedStudentIds.value = []
      
      if ((currentPage.value - 1) * pageSize.value >= total.value - 1) {
        currentPage.value = Math.max(1, currentPage.value - 1)
      }
      
      loading.close()
    } catch (error) {
      console.error('批量删除失败', error)
      ElMessage.error('批量删除失败')
    }
  }).catch(() => {})
}

// 对话框关闭前处理
const handleDialogClose = (done: () => void) => {
  done()
}

// 初始化
onMounted(() => {
  loadAllData()
})
</script>

<style scoped>
/* 引入Tailwind CSS工具类 */
@layer utilities {
  .content-auto {
    content-visibility: auto;
  }
  .transition-all-300 {
    transition: all 0.3s ease;
  }
  .shadow-hover {
    transition: box-shadow 0.3s ease, transform 0.3s ease;
  }
  .shadow-hover:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
  }
}

/* 页面整体样式 */
.dept-management-container {
  padding: 20px;
  background-color: #f8fafc;
  min-height: 100vh;
}

/* 页面头部样式 */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.page-title {
  font-size: 24px;
  font-weight: 600;
  color: #334155;
  margin: 0;
  display: flex;
  align-items: center;
}

.page-title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 24px;
  background-color: #4f46e5;
  margin-right: 10px;
  border-radius: 2px;
}

/* 搜索卡片样式 */
.search-card {
  border-radius: 8px;
  border: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  margin-bottom: 20px;
  transition: all 0.3s ease;
}

.search-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.search-form {
  display: flex;
  align-items: center;
  padding: 16px 20px;
}

.search-input {
  width: 280px;
}

.search-input :deep(.el-input__wrapper) {
  border-radius: 6px;
  padding-left: 10px;
  transition: all 0.2s;
}

.search-input :deep(.el-input__wrapper):hover {
  border-color: #4f46e5;
}

.search-icon {
  color: #94a3b8;
}

.search-btn,
.reset-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: 6px;
  transition: all 0.2s;
}

.search-btn {
  background-color: #4f46e5;
  border-color: #4f46e5;
  color: white;
}

.search-btn:hover {
  background-color: #4338ca;
  border-color: #4338ca;
}

.reset-btn {
  margin-left: 10px;
}

.reset-btn:hover {
  color: #4f46e5;
  border-color: #4f46e5;
}

/* 新增按钮样式 */
.add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: #10b981;
  border-color: #10b981;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 500;
  transition: all 0.2s;
}

.add-btn:hover {
  background-color: #059669;
  border-color: #059669;
  transform: translateY(-1px);
}

.add-btn el-icon {
  margin-right: 6px;
}

/* 数据卡片样式 */
.data-card {
  border-radius: 8px;
  border: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 220px); /* 根据实际布局调整高度 */
}

.data-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.dept-table {
  flex: 1;
  overflow: auto;
}

.dept-table :deep(.el-table__header) {
  background-color: #f1f5f9;
}

.dept-table :deep(.el-table__header th) {
  font-weight: 600;
  color: #334155;
}

.dept-table :deep(.el-table__row) {
  transition: all 0.2s;
}

.dept-table :deep(.el-table__row:hover) {
  background-color: #f8fafc;
}

.dept-table :deep(.el-table__cell) {
  padding: 12px 0;
}

/* 操作按钮样式 */
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border-radius: 6px;
  font-weight: 500;
  transition: all 0.2s;
  margin: 0 4px;
}

.action-btn el-icon {
  margin-right: 4px;
}

.edit-btn {
  background-color: #e0f2fe;
  border-color: #e0f2fe;
  color: #0284c7;
}

.edit-btn:hover {
  background-color: #bae6fd;
  border-color: #bae6fd;
}

.delete-btn {
  background-color: #fee2e2;
  border-color: #fee2e2;
  color: #ef4444;
}

.delete-btn:hover {
  background-color: #fecaca;
  border-color: #fecaca;
}

/* 批量删除容器样式 */
.batch-delete-container {
  padding: 0 20px 16px;
  display: flex;
  justify-content: flex-start;
}

/* 分页容器样式为居中 */
.pagination-container-center {
  padding: 16px 20px;
  display: flex;
  justify-content: center;
  background-color: white;
  border-top: 1px solid #e2e8f0;
}

/* 对话框样式 */
.form-dialog {
  border-radius: 8px;
  overflow: hidden;
}

.form-dialog :deep(.el-dialog__header) {
  background-color: #f8fafc;
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
}

.form-dialog :deep(.el-dialog__title) {
  font-size: 18px;
  font-weight: 600;
  color: #334155;
  display: flex;
  align-items: center;
}

.form-dialog :deep(.el-dialog__title) el-icon {
  margin-right: 8px;
  color: #4f46e5;
}

.form-dialog :deep(.el-dialog__body) {
  padding: 20px;
}

.dialog-form :deep(.el-form-item) {
  margin-bottom: 20px;
}

.dialog-form :deep(.el-form-item__label) {
  font-weight: 500;
  color: #475569;
}

.dialog-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 500;
  transition: all 0.2s;
}

.cancel-btn {
  border: 1px solid #e2e8f0;
  color: #64748b;
}

.cancel-btn:hover {
  border-color: #4f46e5;
  color: #4f46e5;
}

.confirm-btn {
  background-color: #4f46e5;
  border-color: #4f46e5;
  color: white;
}

.confirm-btn:hover {
  background-color: #4338ca;
  border-color: #4338ca;
}
</style>